/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.wisnu.spms.source.model.tableModel;

import com.wisnu.spms.service.entity.DbStudent;
import java.util.ArrayList;
import java.util.List;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author Wisnu Wardoyo
 */
public class PanelSearchListTableModel extends AbstractTableModel {

    List<DbStudent> list = new ArrayList<>();

    public void setList(List<DbStudent> list) {
        this.list = list;
    }

    public List<DbStudent> getList() {
        return list;
    }

    public DbStudent get(int i) {
        return list.get(i);
    }

    @Override
    public int getRowCount() {
        return list.size();
    }

    @Override
    public int getColumnCount() {
        return 2;
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        switch (columnIndex) {
            case 0:
                return list.get(rowIndex).getStudentId();
            case 1:
                return list.get(rowIndex).getStudentName();
            default:
                return null;
        }
    }

    @Override
    public String getColumnName(int column) {
        switch (column) {
            case 0:
                return "Id";
            case 1:
                return "Nama";
            default:
                return null;
        }
    }
}
